lisp/editorconfig: Advise `find-auto-coding` i.s.o `insert-file-contents`
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 18 Jun 2024 03:25:52 +0000 (23:25 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 19 Jun 2024 20:18:58 +0000 (16:18 -0400)
commit0b3e688b230607b0c8571b604621b34860ebccea
treea63fb7d7f9563443a07efc30d7b0386b101ba3b3
parent624ba9fce0624fa1c82a52d9852ecd74a9f3c6c1
lisp/editorconfig: Advise `find-auto-coding` i.s.o `insert-file-contents`

In Emacs<30, we can't use `auto-coding-functions`, but we can get
almost the same result by advising `find-auto-coding`.

* lisp/editorconfig.el (editorconfig-merge-coding-systems): Return nil
if there's no setting.  Don't merge if there's no need.
(editorconfig-set-coding-system-revert); Adjust accordingly.
(editorconfig--filename-codingsystem-hash): Delete var.
(editorconfig--advice-insert-file-contents): Delete function.
(editorconfig--advice-find-file-noselect); Simplify.
(editorconfig--advice-find-auto-coding): New function.
(editorconfig-mode): Use it.
lisp/editorconfig.el